<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        数一:<input type="text" name="num1" id="">
        数二:<input type="text" name="num2" id="">
        数三:<input type="text" name="num3" id="">
        <button>结果</button>
    </div>
    
    <script>
        // 01
        // map操作
       const arr = ['张三','李四','王五']

       const p =  arr.map((item)=>{
            return {uname:item,age:18}
        })
        console.log(p);

        // 02
        // 本地存储
        const obj={uname:'zs',age:18,sex:'男',hobby:['吃饭','睡觉','打豆豆']}
        localStorage.setItem('studentInfo',JSON.stringify(obj))
        const info = JSON.parse(localStorage.getItem('studentInfo'))
        console.log(info);


        // 03 和，差，积
        const arr1 = []
        const item = document.querySelectorAll('[name]');
        const button = document.querySelector('button');
        button.addEventListener('click', function () {
        item.forEach((item,index,arr)=>{
             if(item.type==='text'){
               arr1.push(+item.value) 
             }
        })
         console.log(arr1);

         function res(arr){
            let sum=0
            let dif=0
            let pro=1
            arr.forEach((item)=>{
            sum+=item
            dif-=item
            pro*=item
         })
         return [sum,dif,pro]
         }
         
         const num = res(arr1)
         alert(`
         和=${num[0]}
         差=${num[1]}
         积=${num[2]}
         `)


        });

        
       

        



    </script>
</body>
</html>